/**
 * 根据parent_code查询字典数据
 * @param key_code
 * @returns {Array}
 */
function getDict(key_code) {
    var dict = [];
    Ext.Ajax.request({
        url: '/dict/list_by_keycode',
        params : {'key_code' :key_code},
        method : 'get',
        async:false,
        success: function(response, opts) {
            var result =  Ext.decode(response.responseText);
            Ext.Array.forEach(result,function(obj,index){
                dict[obj.key_code] = obj.key_name;
            });
        },
        failure: function(response, opts) {

        }
    });
    return dict;
}

function getDictStore(key_code) {
    var dict_store = Ext.create('Ext.data.JsonStore',{
        fields : ['id','key_code','key_name'],
        autoLoad:true,
        proxy: {
            type: 'ajax',
            method: 'GET',
            url: '/dict/list_by_keycode?key_code='+key_code,
            reader: {
                type: 'json'
            },
            simpleSortMode: true,
            listeners:{
                'exception':function( theproxy, response, operation, options ){
                    var data = eval("("+response.responseText+")");
                    if(!data.success){
                        Ext.Msg.alert('信息提示',data.msg);
                    } else {
                        Ext.Msg.alert("信息提示","系统忙，请稍候再试");
                    }
                }
            }
        }
    });
    return dict_store;
}

/**
 * 获取产品线
 * @returns {Array}
 */
function getApps() {
    var apps = [];
    Ext.Ajax.request({
        url: '/apps/combo_store',
        method : 'get',
        async:false,
        success: function(response, opts) {
            var result =  Ext.decode(response.responseText);
            Ext.Array.forEach(result,function(obj,index){
                apps[obj.app_id] = obj.app_name;
            });
        },
        failure: function(response, opts) {

        }
    });
    return apps;
}